﻿using System;
using System.Windows;
using System.Windows.Threading;
using FB2er.Properties;

namespace FB2er
{
    public partial class App
    {
        protected override void OnStartup(StartupEventArgs args)
        {
            new SplashScreen(@"Image\Orb256.png").Show(true, true);
            base.OnStartup(args);
            try
            {
                string fileName = null;
                if (args.Args.Length > 0)
                    fileName = args.Args[0];
                else
                    if (Settings.Default.RecentBooks != null && Settings.Default.RecentBooks.Count > 0)
                        fileName = Settings.Default.RecentBooks[0];
                new MainWindow(fileName).Show();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                Shutdown();
            }
        }

        private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.Message);
            e.Handled = true;
        }
    }
}
